package com.heatup.apt.common.dao;

import com.heatup.apt.model.order.VipPurchaseLog;
import com.heatup.apt.model.order.VipPurchaseLogExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Component;

@Component
public interface VipPurchaseLogMapper  {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table vip_purchase_log
     *
     * @mbggenerated
     */
    int countByExample(VipPurchaseLogExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table vip_purchase_log
     *
     * @mbggenerated
     */
    int deleteByExample(VipPurchaseLogExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table vip_purchase_log
     *
     * @mbggenerated
     */
    @Delete({
        "delete from vip_purchase_log",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table vip_purchase_log
     *
     * @mbggenerated
     */
    @Insert({
        "insert into vip_purchase_log (id, user_id, ",
        "order_id, level, ",
        "start_time, end_time, created_by, ",
        "created_time,purchase_type,product_service_id)",
        "values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, ",
        "#{orderId,jdbcType=INTEGER}, #{level,jdbcType=INTEGER}, ",
        "#{startTime,jdbcType=DATE}, #{endTime,jdbcType=DATE}, #{createdBy,jdbcType=INTEGER}, ",
        "#{createdTime,jdbcType=TIMESTAMP}, #{purchaseType,jdbcType=INTEGER},#{productServiceId,jdbcType=INTEGER})"
    })
    int insert(VipPurchaseLog record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table vip_purchase_log
     *
     * @mbggenerated
     */
    int insertSelective(VipPurchaseLog record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table vip_purchase_log
     *
     * @mbggenerated
     */
    List<VipPurchaseLog> selectByExampleWithRowbounds(VipPurchaseLogExample example, RowBounds rowBounds);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table vip_purchase_log
     *
     * @mbggenerated
     */
    List<VipPurchaseLog> selectByExample(VipPurchaseLogExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table vip_purchase_log
     *
     * @mbggenerated
     */
    @Select({
        "select",
        "id, user_id, order_id, level, start_time, end_time, created_by, created_time, purchase_type,product_service_id",
        "from vip_purchase_log",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    VipPurchaseLog selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table vip_purchase_log
     *
     * @mbggenerated
     */
    int updateByExampleSelective(@Param("record") VipPurchaseLog record, @Param("example") VipPurchaseLogExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table vip_purchase_log
     *
     * @mbggenerated
     */
    int updateByExample(@Param("record") VipPurchaseLog record, @Param("example") VipPurchaseLogExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table vip_purchase_log
     *
     * @mbggenerated
     */
    int updateByPrimaryKeySelective(VipPurchaseLog record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table vip_purchase_log
     *
     * @mbggenerated
     */
    @Update({
        "update vip_purchase_log",
        "set user_id = #{userId,jdbcType=INTEGER},",
          "order_id = #{orderId,jdbcType=INTEGER},",
          "level = #{level,jdbcType=INTEGER},",
          "start_time = #{startTime,jdbcType=DATE},",
          "end_time = #{endTime,jdbcType=DATE},",
          "created_by = #{createdBy,jdbcType=INTEGER},",
          "created_time = #{createdTime,jdbcType=TIMESTAMP},",
          "purchase_type = #{purchaseType,jdbcType=INTEGER}",
          "product_service_id = #{productServiceId,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(VipPurchaseLog record);
    
    /**
     * 根据订单Id查询日志
     * @param orderId
     * @return
     */
    VipPurchaseLog quertVipPurchaseLogByOrderId(@Param("orderId") Integer orderId);
    
    /**
     * 根据用户Id查询用户会员日志
     * @param userId
     * @return
     */
    List<VipPurchaseLog> queryVipPurchaseLogByUserId(@Param("userId") Integer userId);
}